package de.medizin.uni.halle.irm;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.AdapterView.OnItemClickListener;


import com.actionbarsherlock.app.SherlockFragment;

public class FeedbackSettingsFragment extends SherlockFragment {
	private SQLiteDatabase database;
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.feedbacksettings, container, false);
		updateImpulseList(view);
		return view;        
		}
	
	private void updateImpulseList(final View view) {
    	database = getSherlockActivity().openOrCreateDatabase("born", Context.MODE_PRIVATE, null);
    	ListView lv  = (ListView) view.findViewById(R.id.feedback_list);
    	int[] to = new int[] { R.id.list_feedback_id, R.id.list_feedback };
        String[] fields = new String[] {"_id", "feedback"};
    	String q = "select * from feedbacks;";
    	Cursor c = database.rawQuery(q, null);
    	CursorAdapter data = new SimpleCursorAdapter(getSherlockActivity(), R.layout.feedback_list, c, fields, to, 0 );
    	lv.setAdapter(data);  
	    lv.setOnItemClickListener(new OnItemClickListener()
	    {
	    	public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
	    	{	
	        }
	     });
	    database.close();
    }

}
